package net.zcscloud.zhuohcun.zeco.controller;

import net.zcscloud.zhuohcun.zeco.common.controller.LogicController;
import net.zcscloud.zhuohcun.zeco.dao.BatchDao;
import net.zcscloud.zhuohcun.zeco.entity.Batch;
import net.zcscloud.zhuohcun.zeco.entity.Usertoken;
import net.zcscloud.zhuohcun.zeco.service.BatchService;
import net.zcscloud.zhuohcun.zeco.service.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "批次实体的控制器")
@RestController
@RequestMapping("/api/batch")
@CrossOrigin(origins = "*")
public class BatchController extends LogicController<BatchService, BatchDao,Batch,Long> {
    public BatchController(@Autowired BatchService service){
        super(service);
    }
    @Autowired
    private BatchDao batchDao;
    @Autowired
    private UserService userService;
    @PostMapping("/getInfo")
    public List<Batch> getInfo(@RequestBody Usertoken usertoken){
        if(userService.verifyToken(usertoken.getToken())=="0"){
            return batchDao.getBatchesByIdNotNull();
        }
        return null;  //token验证错误
    }
}
